package com.sojson.service.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sojson.dao.AdminDao;
import com.sojson.entity.po.Admin;
import com.sojson.service.AdminService;

/**
 * 管理员表Service实现类
 * 
 * @author liu
 * @date 2021-03-16
 */
@Service
public class AdminServiceImpl implements AdminService {

    @Resource
    private AdminDao adminDaoImpl;

    /**
     * 单条插入
     * 
     * @param admin
     * @return
     * @throws SQLException
     */
    @Override
    public int insert(Admin admin) {
        int insert = adminDaoImpl.insert(admin);
        return insert;
    }

    /**
     * 批量插入
     * 
     * @param admin
     * @return
     * @throws SQLException
     */
    @Override
    public int insertList(Admin admin) {
        int insertList = adminDaoImpl.insertList(admin.getAdmins());
        return insertList;
    }

    /**
     * 通过对象批量删除(物理删除)
     * 
     * @param admin
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteByDto(Admin admin) {
        int deleteByDto = adminDaoImpl.deleteByDto(admin);
        return deleteByDto;
    }

    /**
     * 统计全部数量
     * 
     * @return
     * @throws SQLException
     */
    @Override
    public int countAll() {
        int countAll = adminDaoImpl.countAll();
        return countAll;
    }

    /**
     * 查询所有
     * 
     * @return
     * @throws SQLException
     */
    @Override
    public List<Admin> findAll() {
        List<Admin> findAll = adminDaoImpl.listAll();
        return findAll;
    }

    /**
     * 根据对象统计数量
     * 
     * @param admin
     * @return
     * @throws SQLException
     */
    @Override
    public int countByDto(Admin admin) {
        int countByDto = adminDaoImpl.countByDto(admin);
        return countByDto;
    }

    /**
     * 根据对象查询
     * 
     * @param admin
     * @return
     * @throws SQLException
     */
    @Override
    public List<Admin> findByDto(Admin admin) {
        List<Admin> findByDto = adminDaoImpl.listByDto(admin);
        return findByDto;
    }

    /**
     * 通过id删除(物理删除)
     * 
     * @param id
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteById(Integer id) {
        int deleteById = adminDaoImpl.deleteById(id);
        return deleteById;
    }

    /**
     * 通过id列表删除(物理删除)
     * 
     * @param ids
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteByIdList(ArrayList<Integer> ids) {
        int deleteByIdList = adminDaoImpl.deleteByIdList(ids);
        return deleteByIdList;
    }

    /**
     * 通过id更新(全部更新)
     * 
     * @param admin
     * @return
     * @throws SQLException
     */
    @Override
    public int updateById(Admin admin) {
        int updateById = adminDaoImpl.updateById(admin);
        return updateById;
    }

    /**
     * 通过id列表更新(全部更新)(更新内容相同)
     * 
     * @param admin
     * @return
     * @throws SQLException
     */
    @Override
    public int updateStaticByIdList(Admin admin) {
        int updateStaticByIdList = adminDaoImpl.updateStaticByIdList(admin);
        return updateStaticByIdList;
    }

    /**
     * 通过id列表更新(全部更新)(更新内容不相同)
     * 
     * @param admin
     * @return
     * @throws SQLException
     */
    @Override
    public int updateChangeByIdList(Admin admin) {
        int updateChangeByIdList = adminDaoImpl.updateChangeByIdList(admin.getAdmins());
        return updateChangeByIdList;
    }

    /**
     * 通过id更新(局部更新)
     * 
     * @param admin
     * @return
     * @throws SQLException
     */
    @Override
    public int updatePartialById(Admin admin) {
        int updatePartialById = adminDaoImpl.updatePartialById(admin);
        return updatePartialById;
    }

    /**
     * 通过id列表更新(局部更新)(更新内容相同)
     * 
     * @param admin
     * @return
     * @throws SQLException
     */
    @Override
    public int updateStaticPartialByIdList(Admin admin) {
        int updateStaticPartialByIdList = adminDaoImpl.updateStaticPartialByIdList(admin);
        return updateStaticPartialByIdList;
    }

    /**
     * 通过id列表更新(局部更新)(更新内容不相同)
     * 
     * @param admin
     * @return
     * @throws SQLException
     */
    @Override
    public int updateChangePartialByIdList(Admin admin) {
        int updateChangePartialByIdList = adminDaoImpl.updateChangePartialByIdList(admin.getAdmins());
        return updateChangePartialByIdList;
    }

    /**
     * 通过id查询
     * 
     * @param id
     * @return
     * @throws SQLException
     */
    @Override
    public Admin findById(Integer id) {
        Admin findById = adminDaoImpl.findById(id);
        return findById;
    }

    /**
     * 通过id列表查询
     * 
     * @param ids
     * @return
     * @throws SQLException
     */
    @Override
    public ArrayList<Admin> findByIdList(ArrayList<Integer> ids) {
        ArrayList<Admin> findByIdList = adminDaoImpl.findByIdList(ids);
        return findByIdList;
    }

    /**
     * 通过对象查询id列表
     * 
     * @param admin
     * @return
     * @throws SQLException
     */
    @Override
    public ArrayList<Integer> findIdByDto(Admin admin) {
        ArrayList<Integer> findIdByDto = adminDaoImpl.findIdByDto(admin);
        return findIdByDto;
    }

    /**
     * 清空数据(物理清空)
     * 
     * @throws SQLException
     */
    @Override
    public void clear() {
        adminDaoImpl.clear();
    }

}